<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\ManagerRequest;
use App\Http\Requests\ManagerUpdateRequest;
use App\Repositories\ManagerRepositories;
use Illuminate\Http\Request;
use App\Admin\Manager;

class ManagerController extends Controller
{
    protected $repo;

    public function __construct(ManagerRepositories $repo)
    {
        $this->repo = $repo;
    }

    public function index()
    {
        $data = Manager::all();
        return view('admin.manager', compact('data'));
    }

    public function create()
    {
        return view('admin.manager_add');
    }

    public function store(ManagerRequest $request)
    {
        $data = $this->repo->store($request);
        return Manager::create($data) ? '1' : '0';
    }

    public function edit(Manager $manager)
    {
        return view('admin.manager_edit', compact('manager'));
    }

    public function update(ManagerUpdateRequest $request, Manager $manager)
    {
        $data = $this->repo->editdate($request);
        return $manager->update($data) ? '1' : '0';
    }

    public function destroy(Manager $manager)
    {
        return $manager->delete() ? '1' : '0';
    }
}
